import register from "@/components/index/register";

// 表单验证规则
let comfirm_password_validator = (rule, value, callback) => {
  if (value === "") {
    callback(new Error("请再次输入密码"));
  } else if (value !== register.REGISTER.password) {
    callback(new Error("两次输入密码不一致!"));
  } else {
    callback();
  }
};
// 验证规则
const rules = {
  // 注册页使用的规则
  account: [
    { required: true, message: "请输入账号", trigger: "blur" },
    {
      min: 5,
      max: 20,
      message: "长度在 5 到 20 个字符",
      trigger: "blur",
    },
  ],
  password: [
    { required: true, message: "请输入密码", trigger: "blur" },
    { min: 6, message: "至少 6 位", trigger: "blur" },
  ],
  comfirm_password: [
    { validator: comfirm_password_validator, trigger: "blur" },
  ],
  name: [
    { required: true, message: "请输入姓名", trigger: "blur" },
    {
      min: 1,
      max: 10,
      message: "长度在 1 到 10 个字符",
      trigger: "blur",
    },
  ],

  // 登录页使用的规则
  validate_code: [{ required: true, message: "请输入验证码", trigger: "blur" }],

  // 修改密码所用的规则

  // 企业管理
  enterprise_name: [
    { required: true, message: "请输入密码", trigger: "blur" },
    { max: 20, message: "至多 20 位", trigger: "blur" },
  ],
  age: [{ required: true, message: "请输入年龄", trigger: "blur" }],
  gender: [{ required: true, message: "请输入性别", trigger: "blur" }],
  position: [{ required: true, message: "请输入职位", trigger: "blur" }],

  // 救援车辆
  type: [{ required: true, message: "请输入车辆型号", trigger: "blur" }],
  license_number: [
    { required: true, message: "请输入车牌号", trigger: "blur" },
  ],
  driver_name: [
    { required: true, message: "请输入驾驶员姓名", trigger: "blur" },
  ],
  enterprise: [{ required: true, message: "请输入所在企业", trigger: "blur" }],

  // 酒店、景区、旅行社
  star: [{ required: true, message: "请输入星级", trigger: "blur" }],
  location: [{ required: true, message: "请输入地址", trigger: "blur" }],
  parking_space: [{ required: true, message: "请输入停车位", trigger: "blur" }],
  current_parking: [
    { required: true, message: "请输入当前车位", trigger: "blur" },
  ],
  capacity: [{ required: true, message: "请输入容量", trigger: "blur" }],
  current_capacity: [
    { required: true, message: "请输入当前人数", trigger: "blur" },
  ],
  credit: [{ required: true, message: "请输入信用情况", trigger: "blur" }],
  introduction: [
    { required: true, message: "请输入企业介绍", trigger: "blur" },
  ],

  // 在岗导游管理
  academic_degree: [{ required: true, message: "请输入学历", trigger: "blur" }],
  school: [{ required: true, message: "请输入毕业学校", trigger: "blur" }],
  speciality: [{ required: true, message: "请输入专业", trigger: "blur" }],
  agency_name: [{ required: true, message: "请输入所属企业", trigger: "blur" }],

  // 导游申请表
  username: [{ required: true, message: "请输入姓名", trigger: "blur" }],
  phone: [{ required: true, message: "请输入手机号", trigger: "blur" }],
  agency: [{ required: true, message: "请选择意向旅行社", trigger: "blur" }],

  information: [
    { required: true, message: "请输入导游证编号", trigger: "blur" },
  ],

  // 投诉表
  sender: [{ required: true, message: "请输入发送者", trigger: "blur" }],
  enterprise_id: [
    { required: true, message: "请输入投诉对象", trigger: "blur" },
  ],
  level: [{ required: true, message: "请为服务打分", trigger: "blur" }],
  title: [{ required: true, message: "请输入标题", trigger: "blur" }],
  information: [{ required: true, message: "请输入内容", trigger: "blur" }],
  want_agency:[{ required: true, message: "请选择", trigger: "blur" }],
  // 导游申请表
};

export { rules, comfirm_password_validator };
